import { NextFunction, Request, Response } from "express";
import paperSer from './service'
class PaperMidd {
  /**
   *
   * @param req
   * @param res
   * @param next
   */
  isPaperExistByName = async (
    req: Request,
    _res: Response,
    next: NextFunction
  ) => {
    const { name } = req.body;

    try {
        if (await paperSer.isPaperExistByName(name)) {
            next({code: 200, msg: '该答卷已经存在了'})
        } else {
            next()
        }
    } catch(e) {
        next({code: 500, msg: '服务器错误'})
    } 
  };
}
export default new PaperMidd();
